home *** CD-ROM | disk | FTP | other *** search
/ Euroscene 2 / Euroscene 2.iso / USEFUL / DeliTracker130 / Developer / Developer.run / Examples / NoiseTrackerPak.s < prev    next >
Encoding:
Text File  |  1992-09-23  |  12.4 KB  |  758 lines

  1.  
  2.     incdir    "Includes:"
  3.     include "misc/DeliPlayer.i"
  4.  
  5. ;
  6. ;
  7.     SECTION Player,Code
  8. ;
  9. ;
  10.  
  11.     PLAYERHEADER PlayerTagArray
  12.  
  13.     dc.b '$VER: NoiseTracker Packed 1.3D player module V1.0 (02 Sep 92)',0
  14.     even
  15.  
  16. PlayerTagArray
  17.     dc.l    DTP_PlayerVersion,0
  18.     dc.l    DTP_PlayerName,PName
  19.     dc.l    DTP_Creator,CName
  20.     dc.l    DTP_Check2,Chk
  21.     dc.l    DTP_Interrupt,Int
  22.     dc.l    DTP_InitPlayer,InitPlay
  23.     dc.l    DTP_EndPlayer,EndPlay
  24.     dc.l    DTP_InitSound,mt_init
  25.     dc.l    DTP_EndSound,mt_end
  26.     dc.l    TAG_DONE
  27.     
  28. *-----------------------------------------------------------------------*
  29. ;
  30. ; Player/Creatorname und lokale Daten
  31.  
  32. PName    dc.b 'NoiseTrackerPak',0
  33. CName    dc.b 'Mahoney+Kaktus / Riff Raff+Antichrist,',10
  34.     dc.b 'adapted by Delirium',0
  35.     even
  36.  
  37. mt_data        dc.l 0
  38. mt_size        dc.l 0
  39.  
  40. *-----------------------------------------------------------------------*
  41. ;
  42. ;Interrupt für Replay
  43.  
  44. Int
  45.     movem.l    d0-d7/a0-a6,-(sp)
  46.     bsr    mt_music            ; DudelDiDum
  47.     movem.l    (sp)+,d0-d7/a0-a6
  48.     rts
  49.  
  50. *-----------------------------------------------------------------------*
  51. ;
  52. ; Testet auf Modul
  53.  
  54. Chk                        ; NoiseTracker-Compressed ?
  55.     move.l    dtg_ChkData(a5),a0
  56.  
  57.     moveq    #-1,d0                ; Modul nicht erkannt (default)
  58.  
  59.     cmpi.l    #"PATT",$1f6(a0)
  60.     bne.s    ChkEnd
  61.  
  62.     lea    $176(a0),a1            ; is this module corrupt ?
  63.     moveq    #$7f,d0
  64.     moveq    #0,d1
  65.     moveq    #0,d2
  66. ChkSeek    move.b    (a1)+,d1
  67.     cmp.b    d1,d2
  68.     bge.s    ChkNoHi
  69.     move.b    d1,d2
  70. ChkNoHi    dbf    d0,ChkSeek
  71.  
  72.     move.l    dtg_ChkSize(a5),a1
  73.     add.l    a0,a1
  74.     lea    $1f6(a0),a0
  75.     move.w    #$5041,d0
  76.     move.w    #$5454,d1
  77. ChkPatt    cmp.l    a0,a1
  78.     ble.s    ChkEnd                ; yes !
  79.     cmp.w    (a0)+,d0
  80.     bne.s    ChkPatt
  81.     cmp.w    (a0)+,d1
  82.     bne.s    ChkPatt
  83.     subq.b    #1,d2
  84.     bne.s    ChkPatt
  85. ChkOk
  86.     moveq    #0,d0                ; Modul erkannt
  87. ChkEnd
  88.     rts
  89.  
  90. *-----------------------------------------------------------------------*
  91. ;
  92. ; Init Player
  93.  
  94. InitPlay
  95.     moveq    #0,d0
  96.     move.l    dtg_GetListData(a5),a0        ; Function
  97.     jsr    (a0)
  98.     move.l    a0,mt_data
  99.     move.l    d0,mt_size
  100.  
  101.     move.l    dtg_AudioAlloc(a5),a0        ; Function
  102.     jsr    (a0)                ; returncode is already set !
  103.     rts
  104.  
  105. *-----------------------------------------------------------------------*
  106. ;
  107. ; End Player
  108.  
  109. EndPlay
  110.     move.l    dtg_AudioFree(a5),a0        ; Function
  111.     jsr    (a0)
  112.     rts
  113.  
  114. *-----------------------------------------------------------------------*
  115. ;
  116. ; NoiseTracker-Compressed
  117.  
  118. ;*******************************
  119. ;*** NOISETRACKER COMPRESSED ***
  120. ;*** REPLAYROUTINE 1.3 D     ***
  121. ;*** IMPROVED ON 15/03/91    ***
  122. ;*** BY ANTICHRIST OF UFO    ***
  123. ;*******************************
  124.  
  125. ; This routine is fully pc-relative.
  126. ; Don't change anything in mt_vars
  127. ; ('coz the offsets below won't fit anymore!).
  128.  
  129. ; Include your PACKED module at mt_data (still the same!)
  130. ; To init, jump to Offset 0
  131. ; »» Load your start position to d0.l ««
  132. ; To play, jump to Offset 4
  133. ; To stop, jump to Offset 8
  134.  
  135. ;***************
  136. ;*** EXAMPLE ***
  137. ;***************
  138. ;    moveq    #0,d0            ;Start at position 0
  139. ;    lea    music(pc),a0        ;the replayroutine
  140. ;    jsr    (a0)            ;call mt_init
  141. ;    move.l    $6c.w,oldLevel3        ;save the irq vector
  142. ;    move.l    #newLevel3,$6c.w    ;set my irq
  143. ;wait:    btst    #6,$bfe001        ;wait for left mousebutton
  144. ;    bne.s    wait    
  145. ;    move.l    oldLevel3(pc),$6c.w    ;reset irq vector
  146. ;    lea    music(pc),a0
  147. ;    jsr    8(a0)            ;call mt_end
  148. ;    clr.l    d0
  149. ;    rts
  150. ;
  151. ;oldLevel3: dc.l 0
  152. ;
  153. ;newLevel3:
  154. ;    movem.l    d0-d7/a0-a6,-(sp)    ;save registers
  155. ;    move.w    $dff01e,d0        ;read inreqr
  156. ;    btst    #5,d0            ;was it a vblank irq?
  157. ;    beq.s    novblank        ;no, so exit
  158. ;    lea    music(pc),a0        
  159. ;    jsr    4(a0)            ;call mt_music
  160. ;novblank:
  161. ;    move.w    #$0070,$dff09c        ;clear the level3 bits
  162. ;    movem.l    (sp)+,d0-d7/a0-a6    ;get registers back
  163. ;    rte                ;return
  164.  
  165.  
  166.  
  167. mt_speed    =0
  168. mt_songpos    =1
  169. mt_pattpos    =2
  170. mt_counter    =4
  171. mt_break    =5
  172. mt_dmacon    =6
  173. mt_samplestarts =8
  174. mt_voice1    =132
  175. mt_voice2    =166
  176. mt_voice3    =200
  177. mt_voice4    =234
  178.  
  179.  
  180. music:
  181.     jmp    mt_init(pc)        ;Offset 0
  182.     jmp    mt_music(pc)        ;Offset 4
  183.     jmp    mt_end(pc)        ;Offset 8
  184.  
  185. mt_init:
  186.     move.l    d0,-(sp)
  187.     lea    mt_vars(pc),a4
  188.     move.l    mt_data(pc),a0
  189.     move.l    a0,a1
  190.     lea    $176(a1),a1
  191.     moveq    #$7f,d0
  192.     moveq    #0,d1
  193.     moveq    #0,d2
  194.  
  195. .seek    move.b    (a1)+,d1
  196.     cmp.b    d1,d2
  197.     bge.s    .nohi
  198.     move.b    d1,d2
  199. .nohi    dbf    d0,.seek
  200.  
  201.     move.l    mt_data(pc),a0
  202.     lea    $1f6(a0),a0
  203.     lea    mt_patterns(pc),a1
  204.     move.w    #$5041,d0
  205.     move.w    #$5454,d1
  206. .getPatt
  207.     cmp.w    (a0)+,d0
  208.     bne.s    .getPatt
  209.     cmp.w    (a0)+,d1
  210.     bne.s    .getPatt
  211.     move.l    a0,(a1)+
  212.     dbf    d2,.getPatt
  213.  
  214.     lea    mt_samplestarts(a4),a1
  215.     move.l    mt_data(pc),a2
  216.     move.l    a2,d2
  217.     moveq    #31-1,d1
  218. mt_lop3:
  219.     move.l    (a2),d0
  220.     add.l    d2,d0
  221.     move.l    d0,(a1)+
  222.     lea    12(a2),a2
  223.     dbf    d1,mt_lop3
  224.  
  225.     move.l    (sp)+,d0
  226.     moveq    #0,d0            ;insert this line, if you don't
  227.     bsr    setChannel        ;want to start your song at any 
  228.                     ;other position than 0
  229. ;    bset    #1,$bfe001
  230.     move.b    #6,mt_speed(a4)
  231.     clr.w    $dff0a8
  232.     clr.w    $dff0b8
  233.     clr.w    $dff0c8
  234.     clr.w    $dff0d8
  235.     clr.b    mt_counter(a4)
  236.     clr.w    mt_pattpos(a4)
  237.     rts
  238.  
  239. mt_end:
  240.     clr.w    $dff0a8
  241.     clr.w    $dff0b8
  242.     clr.w    $dff0c8
  243.     clr.w    $dff0d8
  244.     move.w    #$f,$dff096
  245.     rts
  246.  
  247. mt_music:
  248.     lea    mt_vars(pc),a4
  249.     addq.b    #1,mt_counter(a4)
  250.     move.b    mt_counter(a4),D0
  251.     cmp.b    mt_speed(a4),D0
  252.     blt.s    mt_nonew
  253.     clr.b    mt_counter(a4)
  254.     bra    mt_getnew
  255.  
  256. mt_nonew:
  257.     lea    mt_voice1(a4),a6
  258.     lea    $dff0a0,a5
  259.     bsr    mt_checkcom
  260.     lea    mt_voice2(a4),a6
  261.     lea    $10(a5),a5
  262.     bsr    mt_checkcom
  263.     lea    mt_voice3(a4),a6
  264.     lea    $10(a5),a5
  265.     bsr    mt_checkcom
  266.     lea    mt_voice4(a4),a6
  267.     lea    $10(a5),a5
  268.     bsr    mt_checkcom
  269.     bra    mt_endr
  270.  
  271. mt_arpeggio:
  272.     moveq    #0,d0
  273.     move.b    mt_counter(a4),d0
  274.     divs    #3,d0
  275.     swap    d0
  276.     cmp.w    #0,d0
  277.     beq.s    mt_arp2
  278.     cmp.w    #2,d0
  279.     beq.s    mt_arp1
  280.  
  281.     moveq    #0,d0
  282.     move.b    3(a6),d0
  283.     lsr.b    #4,d0
  284.     bra.s    mt_arp3
  285. mt_arp1:
  286.     moveq    #0,d0
  287.     move.b    $3(a6),d0
  288.     and.b    #$f,d0
  289.     bra.s    mt_arp3
  290. mt_arp2:
  291.     move.w    $10(a6),d2
  292.     bra.s    mt_arp4
  293. mt_arp3:
  294.     asl.w    #1,d0
  295.     moveq    #0,d1
  296.     move.w    $10(a6),d1
  297.     lea    mt_periods(pc),a0
  298.     moveq    #$24,d7
  299. mt_arploop:
  300.     move.w    (a0,d0.w),d2
  301.     cmp.w    (a0),d1
  302.     bge.s    mt_arp4
  303.     addq.l    #2,a0
  304.     dbf    d7,mt_arploop
  305.     rts
  306. mt_arp4:move.w    d2,$6(a5)
  307.     rts
  308.  
  309. mt_getnew:
  310.     move.l    mt_data(pc),a3
  311.     clr.w    mt_dmacon(a4)
  312.     lea    $dff0a0,a5
  313.     lea    mt_voice1(a4),a6
  314.     bsr.s    mt_playvoice
  315.     lea    $10(a5),a5
  316.     lea    mt_voice2(a4),a6
  317.     bsr.s    mt_playvoice
  318.     lea    $10(a5),a5
  319.     lea    mt_voice3(a4),a6
  320.     bsr.s    mt_playvoice
  321.     lea    $10(a5),a5
  322.     lea    mt_voice4(a4),a6
  323.     bsr.s    mt_playvoice
  324.     bra    mt_setdma
  325.  
  326. mt_playvoice:
  327.     tst.w    32(a6)
  328.     beq.s    .nodelay
  329.     subq.w    #1,32(a6)
  330.     bra.s    .morevoice
  331. .nodelay
  332.     move.l    28(a6),a0
  333.     moveq    #0,d2
  334.     move.b    (a0),d2
  335.     cmpi.b    #$ff,d2
  336.     bne.s    .nocrunch
  337.     move.b    1(a0),33(a6)
  338.     addq.l    #2,28(a6)
  339.     clr.l    (a6)
  340.     bra.s    mt_playvoice
  341. .nocrunch
  342.     move.b    d2,d0
  343.     andi.b    #$3f,d2
  344.     beq.s    .noset
  345.     lsl.w    #1,d2
  346.     lea    mt_periods(pc),a1
  347.     move.w    -2(a1,d2.w),d2
  348. .noset    btst    #7,d0
  349.     beq.s    .nohisamp
  350.     bset    #12,d2
  351. .nohisamp
  352.     move.w    d2,(a6)
  353.     move.b    1(a0),2(a6)
  354.     clr.b    3(a6)
  355.     btst    #6,d0
  356.     bne.s    .nocom
  357.     move.b    2(a0),3(a6)
  358.     addq.l    #1,28(a6)
  359. .nocom    addq.l    #2,28(a6)
  360. .morevoice
  361.     moveq    #0,d2
  362.     move.b    2(a6),d2
  363.     and.b    #$f0,d2
  364.     lsr.b    #4,d2
  365.     move.b    (a6),d0
  366.     and.b    #$f0,d0
  367.     or.b    d0,d2
  368.     tst.b    d2
  369.     beq.s    mt_setregs
  370.     lea    mt_samplestarts(a4),a1
  371.     subq.l    #1,d2
  372.     move.l    d2,d4
  373.     mulu    #12,d4                
  374.     asl.l    #2,d2                
  375.     move.l    (a1,d2.l),4(a6)            
  376.     move.w    4(a3,d4.l),8(a6)        
  377.     move.w    6(a3,d4.l),18(a6)        
  378.     moveq    #0,d3
  379.     move.w    8(a3,d4.l),d3
  380.     tst.w    d3
  381.     beq.s    mt_noloop
  382.     move.l    4(a6),d2
  383.     lsl.l    #1,d3
  384.     add.l    d3,d2
  385.     move.l    d2,$a(a6)
  386.     move.w    8(a3,d4.l),d0
  387.     add.w    10(a3,d4.l),d0
  388.     move.w    d0,8(a6)
  389.     move.w    10(a3,d4.l),$e(a6)
  390.     move.w    $12(a6),$8(a5)
  391.     bra.s    mt_setregs
  392. mt_noloop:
  393.     move.l    4(a6),d2
  394.     add.l    d3,d2
  395.     move.l    d2,10(a6)
  396.     move.w    10(a3,d4.l),14(a6)
  397.     move.w    18(a6),8(a5)
  398. mt_setregs:
  399.     move.w    (a6),d0
  400.     andi.w    #$fff,d0
  401.     beq    mt_checkcom2
  402.     move.b    2(a6),d0
  403.     and.b    #$F,d0
  404.     cmp.b    #$3,d0
  405.     bne.s    mt_setperiod
  406.     bsr    mt_setmyport
  407.     bra    mt_checkcom2
  408.  
  409. mt_setperiod:
  410.     move.w    (a6),$10(a6)
  411.     and.w    #$fff,$10(a6)
  412.     move.w    $14(a6),d0
  413.     move.w    d0,$dff096
  414.     clr.b    $1b(a6)
  415.  
  416.     move.l    4(a6),(a5)
  417.     move.w    8(a6),4(a5)
  418.     move.w    $10(a6),d0
  419.     and.w    #$fff,d0
  420.     move.w    d0,$6(a5)
  421.     move.w    20(a6),d0
  422.     or.w    d0,mt_dmacon(a4)
  423.     bra    mt_checkcom2
  424.  
  425. mt_setdma:
  426.     move.w    mt_dmacon(a4),d0
  427.     beq.s    mt_nodma
  428.     bsr    mt_wait
  429.     or.w    #$8000,d0
  430.     move.w    d0,$dff096
  431.     bsr    mt_wait
  432. mt_nodma:
  433.     lea    $dff000,a5
  434.     lea    mt_voice4(a4),a6
  435.     move.l    $a(a6),$d0(a5)
  436.     move.w    $e(a6),$d4(a5)
  437.     lea    mt_voice3(a4),a6
  438.     move.l    $a(a6),$c0(a5)
  439.     move.w    $e(a6),$c4(a5)
  440.     lea    mt_voice2(a4),a6
  441.     move.l    $a(a6),$b0(a5)
  442.     move.w    $e(a6),$b4(a5)
  443.     lea    mt_voice1(a4),a6
  444.     move.l    $a(a6),$a0(a5)
  445.     move.w    $e(a6),$a4(a5)
  446.     addq.b    #1,mt_pattpos+1(a4)
  447.     cmpi.b    #64,mt_pattpos+1(a4)
  448.     bne.s    mt_endr
  449. mt_nex:    clr.b    mt_pattpos+1(a4)
  450.     clr.b    mt_break(a4)
  451.     addq.b    #1,mt_songpos(a4)
  452.     andi.b    #$7f,mt_songpos(a4)
  453.     move.b    mt_songpos(a4),d1
  454.     move.l    mt_data(pc),a0
  455.     cmp.b    $174(a0),d1        
  456.     bne.s    .not
  457.     move.b    $175(a0),mt_songpos(a4)    
  458. .not    moveq    #0,d0
  459.     move.b    mt_songpos(a4),d0
  460.     bsr    setChannel
  461. mt_endr:
  462.     tst.b    mt_break(a4)
  463.     bne.s    mt_nex
  464.     rts
  465.  
  466. mt_wait:moveq    #4,d3
  467. mt_wai2:move.b    $dff006,d2
  468. mt_wai3:cmp.b    $dff006,d2
  469.     beq.s    mt_wai3
  470.     dbf    d3,mt_wai2
  471.     rts
  472.  
  473. mt_setmyport:
  474.     move.w    (a6),d2
  475.     and.w    #$fff,d2
  476.     move.w    d2,$18(a6)
  477.     move.w    $10(a6),d0
  478.     clr.b    $16(a6)
  479.     cmp.w    d0,d2
  480.     beq.s    mt_clrport
  481.     bge.s    mt_rt
  482.     move.b    #$1,$16(a6)
  483.     rts
  484. mt_clrport:
  485.     clr.w    $18(a6)
  486. mt_rt:    rts
  487.  
  488. mt_myport:
  489.     move.b    3(a6),d0
  490.     beq.s    mt_myslide
  491.     move.b    d0,$17(a6)
  492.     clr.b    3(a6)
  493. mt_myslide:
  494.     tst.w    $18(a6)
  495.     beq.s    mt_rt
  496.     moveq    #0,d0
  497.     move.b    $17(a6),d0
  498.     tst.b    $16(a6)
  499.     bne.s    mt_mysub
  500.     add.w    d0,$10(a6)
  501.     move.w    $18(a6),d0
  502.     cmp.w    $10(a6),d0
  503.     bgt.s    mt_myok
  504.     move.w    $18(a6),$10(a6)
  505.     clr.w    $18(a6)
  506. mt_myok:move.w    $10(a6),$6(a5)
  507.     rts
  508. mt_mysub:
  509.     sub.w    d0,$10(a6)
  510.     move.w    $18(a6),d0
  511.     cmp.w    $10(a6),d0
  512.     blt.s    mt_myok
  513.     move.w    $18(a6),$10(a6)
  514.     clr.w    $18(a6)
  515.     move.w    $10(a6),$6(a5)
  516.     rts
  517.  
  518. mt_vib:    move.b    3(a6),d0
  519.     beq.s    mt_vi
  520.     move.b    d0,$1a(a6)
  521.  
  522. mt_vi:    move.b    $1b(a6),d0
  523.     lea    mt_sin(pc),a4
  524.     lsr.w    #$2,d0
  525.     and.w    #$1f,d0
  526.     moveq    #0,d2
  527.     move.b    (a4,d0.w),d2
  528.     move.b    $1a(a6),d0
  529.     and.w    #$f,d0
  530.     mulu    d0,d2
  531.     lsr.w    #$6,d2
  532.     move.w    $10(a6),d0
  533.     tst.b    $1b(a6)
  534.     bmi.s    mt_vibmin
  535.     add.w    d2,d0
  536.     bra.s    mt_vib2
  537. mt_vibmin:
  538.     sub.w    d2,d0
  539. mt_vib2:move.w    d0,$6(a5)
  540.     move.b    $1a(a6),d0
  541.     lsr.w    #$2,d0
  542.     and.w    #$3c,d0
  543.     add.b    d0,$1b(a6)
  544.     lea    mt_vars(pc),a4
  545.     rts
  546.  
  547. mt_nop:    move.w    $10(a6),$6(a5)
  548.     rts
  549.  
  550. mt_checkcom:
  551.     move.w    2(a6),d0
  552.     and.w    #$fff,d0
  553.     beq.s    mt_nop
  554.     move.b    2(a6),d0
  555.     and.b    #$f,d0
  556.     tst.b    d0
  557.     beq    mt_arpeggio
  558.     cmp.b    #$1,d0
  559.     beq.s    mt_portup
  560.     cmp.b    #$2,d0
  561.     beq    mt_portdown
  562.     cmp.b    #$3,d0
  563.     beq    mt_myport
  564.     cmp.b    #$4,d0
  565.     beq    mt_vib
  566.     move.w    $10(a6),$6(a5)
  567.     cmp.b    #$a,d0
  568.     beq.s    mt_volslide
  569.     rts
  570.  
  571. mt_volslide:
  572.     moveq    #0,d0
  573.     move.b    $3(a6),d0
  574.     lsr.b    #4,d0
  575.     tst.b    d0
  576.     beq.s    mt_voldown
  577.     add.w    d0,$12(a6)
  578.     cmp.w    #$40,$12(a6)
  579.     bmi.s    mt_vol2
  580.     move.w    #$40,$12(a6)
  581. mt_vol2:move.w    $12(a6),$8(a5)
  582.     rts
  583.  
  584. mt_voldown:
  585.     moveq    #0,d0
  586.     move.b    $3(a6),d0
  587.     and.b    #$f,d0
  588.     sub.w    d0,$12(a6)
  589.     bpl.s    mt_vol3
  590.     clr.w    $12(a6)
  591. mt_vol3:move.w    $12(a6),$8(a5)
  592.     rts
  593.  
  594. mt_portup:
  595.     moveq    #0,d0
  596.     move.b    3(a6),d0
  597.     sub.w    d0,$10(a6)
  598.     move.w    $10(a6),d0
  599.     and.w    #$fff,d0
  600.     cmp.w    #$71,d0
  601.     bpl.s    mt_por2
  602.     and.w    #$f000,$10(a6)
  603.     or.w    #$71,$10(a6)
  604. mt_por2:move.w    $10(a6),d0
  605.     and.w    #$fff,d0
  606.     move.w    d0,$6(a5)
  607.     rts
  608.  
  609. mt_portdown:
  610.     clr.w    d0
  611.     move.b    $3(a6),d0
  612.     add.w    d0,$10(a6)
  613.     move.w    $10(a6),d0
  614.     and.w    #$fff,d0
  615.     cmp.w    #$358,d0
  616.     bmi.s    mt_por3
  617.     and.w    #$f000,$10(a6)
  618.     or.w    #$358,$10(a6)
  619. mt_por3:move.w    $10(a6),d0
  620.     and.w    #$fff,d0
  621.     move.w    d0,$6(a5)
  622.     rts
  623.  
  624. mt_checkcom2:
  625.     move.b    2(a6),d0
  626.     and.b    #$f,d0
  627.     cmp.b    #$e,d0
  628.     beq.s    mt_setfilt
  629.     cmp.b    #$d,d0
  630.     beq.s    mt_pattbreak
  631.     cmp.b    #$b,d0
  632.     beq.s    mt_posjmp
  633.     cmp.b    #$c,d0
  634.     beq.s    mt_setvol
  635.     cmp.b    #$f,d0
  636.     beq.s    mt_setspeed
  637.     rts
  638.  
  639. mt_setfilt:
  640.     move.b    $3(a6),d0
  641.     and.b    #$1,d0
  642.     asl.b    #$1,d0
  643.     and.b    #$fd,$bfe001
  644.     or.b    d0,$bfe001
  645.     rts
  646. mt_posjmp:
  647.     move.b    3(a6),d0
  648.     subq.b    #1,d0
  649.     move.b    d0,mt_songpos(a4)
  650. mt_pattbreak:
  651.     not.b    mt_break(a4)
  652.     rts
  653. mt_setvol:
  654.     cmp.b    #$40,$3(a6)
  655.     ble.s    mt_vol4
  656.     move.b    #$40,$3(a6)
  657. mt_vol4:
  658.     move.b    $3(a6),$8(a5)
  659.     rts
  660.  
  661. mt_setspeed:
  662.     cmp.b    #$1f,$3(a6)
  663.     ble.s    mt_sets
  664.     move.b    #$1f,$3(a6)
  665. mt_sets:
  666.     move.b    $3(a6),d0
  667.     beq.s    mt_rts2
  668.     move.b    d0,mt_speed(a4)
  669.     clr.b    mt_counter(a4)
  670. mt_rts2:
  671.     rts
  672.  
  673. setChannel:
  674.     lea    mt_vars(pc),a4
  675.     move.l    mt_data(pc),a0
  676.     cmp.b    $174(a0),d0
  677.     blt.s    .valid
  678.     moveq    #0,d0
  679. .valid    move.b    d0,mt_songpos(a4)
  680.     lea    $176(a0),a0
  681.     move.b    (a0,d0.w),d0
  682.     lsl.l    #2,d0
  683.     lea    mt_voice1(a4),a1
  684.     lea    mt_patterns(pc),a0
  685.     move.l    (a0,d0.w),a0
  686.     move.l    a0,d2
  687.     move.l    d2,d0
  688.     addq.l    #6,d0
  689.     moveq    #3,d1
  690.     bra.s    .dochan
  691. .setchannel
  692.     lea    34(a1),a1
  693.     moveq    #0,d0
  694.     move.w    (a0)+,d0
  695.     add.l    d2,d0
  696. .dochan
  697.     move.l    d0,28(a1)
  698.     clr.w    32(a1)
  699.     dbf    d1,.setchannel
  700.     rts
  701.  
  702. mt_sin:
  703.  DC.b $00,$18,$31,$4a,$61,$78,$8d,$a1,$b4,$c5,$d4,$e0,$eb,$f4,$fa,$fd
  704.  DC.b $ff,$fd,$fa,$f4,$eb,$e0,$d4,$c5,$b4,$a1,$8d,$78,$61,$4a,$31,$18
  705.  
  706. mt_periods:
  707.  DC.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c,$023a,$021a,$01fc,$01e0
  708.  DC.w $01c5,$01ac,$0194,$017d,$0168,$0153,$0140,$012e,$011d,$010d,$00fe
  709.  DC.w $00f0,$00e2,$00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097,$008f,$0087
  710.  DC.w $007f,$0078,$0071
  711.  
  712. mt_patterns:
  713.     dcb.l    64
  714. mt_vars:            ;*** DON'T CHANGE ANYTHING BELOW ***
  715.     DC.b    6
  716.     DC.b    0
  717.     DC.w    0
  718.     DC.b    0
  719.     DC.b    0
  720.     DC.w    0
  721. ;mt_samplestarts
  722.     dcb.L    $1f
  723.  
  724. ;mt_voice1
  725.     dcb.w    10
  726.     DC.w    1
  727.     dcb.w    3
  728.     dc.l    0        
  729.     dc.w    0        
  730.  
  731. ;mt_voice2
  732.     dcb.w    10
  733.     DC.w    2
  734.     dcb.w    3
  735.     dc.l    0
  736.     dc.w    0
  737.     
  738. ;mt_voice3
  739.     dcb.w    10
  740.     DC.w    4
  741.     dcb.w    3
  742.     dc.l    0
  743.     dc.w    0
  744.     
  745. ;mt_voice4
  746.     dcb.w    10
  747.     DC.w    8
  748.     dcb.w    3
  749.     dc.l    0
  750.     dc.w    0
  751.  
  752. ;mt_data:
  753. ;    INCBIN    dh0:sfx/modules/mymod.pak
  754.  
  755.  
  756. ;atdp Coke's Touchdown !
  757.  
  758.